var path = require('path');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
    devtool: 'cheap-module-eval-source-map',
    entry: [
        'webpack-hot-middleware/client',
        path.join(__dirname, 'src/frontend/index.js')
    ],
    output: {
        path: path.join(__dirname, 'build/statics'),
        filename: 'bundle.js',
        publicPath: '/'
    },
    plugins: [
        new webpack.optimize.UglifyJsPlugin({
            output: {
                comments: false,
            },
            compress: {
                warnings: false
            }
        }),
        new HtmlWebpackPlugin({
            template: path.join(__dirname, "src/frontend/index.html"),
            hash: false,
            filename: path.join(__dirname, "build/statics/index.html"),
            inject: 'body',
            minify: {
                collapseWhitespace: true
            }
        }),
        new webpack.optimize.OccurenceOrderPlugin(),
        new webpack.HotModuleReplacementPlugin(),

        new webpack.NoErrorsPlugin()
    ],
    module: {
        loaders: [
            {
                test: /\.js$/,
                loader: 'babel-loader?compact=false',
                include: __dirname,
            },
            {
                test: /\.(less)$/,
                loader: "style!css!less"
            },
            {
                test: /\.(css)$/,
                include: /node_modules/,
                loader: "style!css"
            },
            {
                test: /\.(png|jpg)$/,
                loader: 'url?limit=25000'
            }
        ]
    },
    externals: {
        'react': "React",
        'react-dom': "ReactDOM"
    }
};
